﻿namespace ServoDrivesLibAbstract
{
    public interface IEtherCATMode
    {
        /// <summary>
        /// 扫描总线
        /// </summary>
        /// <returns>错误码</returns>
        int StartScan();
        /// <summary>
        /// 停止扫描总线
        /// </summary>
        /// <returns></returns>
        int EndScan();
        /// <summary>
        /// 设置通讯周期
        /// </summary>
        /// <param name="cycleTime"></param>
        /// <returns></returns>
        int SetCycleTime(int cycleTime);
        /// <summary>
        /// 停止EtherCAT总线
        /// </summary>
        /// <returns>错误码</returns>
        int StopEtherCAT();
        /// <summary>
        /// 获取总线的通讯时间
        /// </summary>
        /// <param name="averageTime">平均值时间(us)</param>
        /// <param name="maxTime">最大时间(us)</param>
        /// <param name="cycles">帧间隔(us)</param>
        /// <returns>错误码</returns>
        int GetEtherCATConsumeTime(ref UInt64 averageTime, ref UInt64 maxTime, ref UInt64 cycles);
        /// <summary>
        /// 获取从站数量
        /// </summary>
        /// <param name="slaveValue">从站数</param>
        /// <returns>错误码</returns>
        int GetSlaveValue(ref int slaveValue);
        /// <summary>
        /// Pdo读
        /// </summary>
        /// <param name="slave">主索引</param>
        /// <param name="index">主索引</param>
        /// <param name="subIndex">子索引</param>
        /// <param name="valueLength">读取字节长度</param>
        /// <param name="value">读取数据</param>
        /// <returns>错误码</returns>
        int PDORead(int slave, int index, int subIndex, int valueLength, ref int value);
        /// <summary>
        /// Pdo写
        /// </summary>
        /// <param name="slave">主索引</param>
        /// <param name="index">主索引</param>
        /// <param name="subIndex">子索引</param>
        /// <param name="valueLength">读取字节长度</param>
        /// <param name="value">写入数据</param>
        /// <returns>错误码</returns>
        int PDOWrite(int slave, int index, int subIndex, int valueLength, int value);
        /// <summary>
        /// Sdo读
        /// </summary>
        /// <param name="slave">主索引</param>
        /// <param name="index">主索引</param>
        /// <param name="subIndex">子索引</param>
        /// <param name="valueLength">读取字节长度</param>
        /// <param name="value">读取数据</param>
        /// <returns>错误码</returns>

        int SDORead(int slave, int index, int subIndex, int valueLength, ref int value);
        /// <summary>
        /// Sdo写
        /// </summary>
        /// <param name="slave">主索引</param>
        /// <param name="index">主索引</param>
        /// <param name="subIndex">子索引</param>
        /// <param name="valueLength">读取字节长度</param>
        /// <param name="value">写入数据</param>
        /// <returns>错误码</returns>
        int SDOWrite(int slave, int index, int subIndex, int valueLength, int value);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        int GetErrorCode(ref int code);
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        int ClearErrorCode();
    }
}
